/**
 * Authors:
 * Vladimír Matěna
 * Jan Skalický
 */
package inireader;

import java.util.List;

/**
 * Class used for limiting values of property elements. Simulating Enum type.
 */
public final class EnumRestriction extends Restriction
{
	List<String> values;

	/**
	 * Creates EnumRestriction.
	 * @param values list of Enum values
	 * @param property for this property
	 */
	public EnumRestriction(List<String> values, Property property)
	{
		super(property);
		
		this.values = values;
	}

	/**
	 * Validates value, in case of bad formatting throws exception.
	 * @param value value to validate
	 */
	public void validateRestrictedValue(String value)
	{
		if (!values.contains(value))
		{
			throw new ValidatingException(String.format("Value %s is not in enum of property %s!", value, property.getName().getId()));
		}
	}
}
